<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

<h:head>
		 
</h:head>
<h:body>
	<ui:composition template="/layout/layout.xhtml">	
		<ui:define name="conteudo">
		<p:dialog 
			id="modalEmpresa"
			widgetVar="modalEditEmpresa"
			closeOnEscape="true"
			width="800"
			height="500"			
			dynamic="true"
			appendTo=""
			modal="true">		
		</p:dialog>
			<h:form>		
				<p:tabView>
			        <p:tab title="Pesquisar">
			            <p:dataTable 
			            	id="tableEmpresas" 
			            	var="_empresa" 
			            	value="#{empresaBean.empresas}" 
			            	paginator="true" 
			            	rows="5"
			            	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"		            	
	                        rowsPerPageTemplate="5,10,15"
	                        selectionMode="single"	                        
	                        selection="#{empresaBean.empresaSelecionada}"
	                        rowKey="#{_empresa.id}">                
	                        <p:ajax event="rowSelect" listener="#{empresaBean.modalEditEmpresa()}" oncomplete="PF('modalEditEmpresa').show()" />        
			            	<p:column headerText="CPF/CNPJ">
			            		<h:outputText value="#{_empresa.cpfCnpj}" />
			            	</p:column>
			            	<p:column headerText="Razâo Social">
			            		<h:outputText value="#{_empresa.razao}" />
			            	</p:column>		            	
			            </p:dataTable>
			        </p:tab>
			    </p:tabView>
		    </h:form>
		</ui:define>
	</ui:composition>      
</h:body>
</html>
